﻿@model Sharp.WebBooter.Areas.Demo.Models.GroupIndexModel
@{
    var x = Html.X();
}
<script>
    function windowViewModel() {
        var self = this;
        self.selectThis = function(button) {

            var grid = button.ownerGrid || button.up("grid");
            var selected = grid.getSelectionModel().getSelection();
            if (selected.length < 1) {
                Tip("请选中一行。");
                return false;
            }
            var container = Ext.getCmp(grid.tag.controlId);
            if (container == null) {
                Tip("containerId不正确。");
                return false;
            }
            var textfield = container.down("textfield");
            textfield.setValue(selected[0].data.Title);

            var hiddenContainer = container.down("hidden");
            hiddenContainer.setValue(selected[0].data.Id);

            App.Edit.CloseWindow(button);
            return true;
        }
    }
</script>
@(Html.X().Window()
          .Width(700)
          .Height(500)
          .Icon(Icon.Clock)
          .Title("Server Time").Layout(LayoutType.Fit)

          .CloseAction(CloseAction.Destroy)
    .Items(x.GridPanel()
        .Tag(new
        {
            ModuleId = Model.ModuleId,
            controlId = Request.Form["controlId"]
        })
        .Title(Model.PageTitle)
        .Store(x.StoreForModel().Proxy(
        x.AjaxProxy().ExtraParams(pp =>
        {
        })
        .Url(Url.Action("GetPaged","Data")).Post().Reader(x.JsonReader().RootProperty("data"))).RemoteSort(true).RemotePaging(true).PageSize(25)
        .SorterFor(Model, m => m.Id, Ext.Net.SortDirection.DESC)
        )
        .SelectionModel(x.RowSelectionModel())
        .ColumnModel(
            x.ColumnFor(m => m.Id),
            x.ColumnFor(m => m.Code),
            x.ColumnFor(m => m.Title),
            x.ColumnFor(m => m.MemberCount),
            x.ColumnFor(m => m.Remark),
            x.ColumnFor(m => m.CreatedTime),
            x.ColumnFor(m => m.ModifiTime)
                    )
        .BottomBar(x.PagingToolbar())
        .EmptyText("无数据。")
        .View(x.GridView().StripeRows(true).TrackOver(true)).Listeners(ls =>
        {
            ls.RowDblClick.Fn = "function(row){new windowViewModel().selectThis(row)}";
        })
 .Buttons(
        x.Button().Text("确定").OnClientClick("new windowViewModel().selectThis(this)"),
        x.Button().Text("关闭").OnClientClick("App.Edit.CloseWindow(this)"))
      )

)